

function HistoryTyphoonRightButton(id) {
    $.ajax({
        type: "get",
        url: basepath + "/history/damaged/" + id,
        contentType: 'application/json',
        dataType: "json",
        data: {},
        success: function (res) {

            var data = res.data;
            $("#subContext2020818 .aside-subContext:eq(0) .aside-txt1:eq(0) .aside-count").text(data.line.total || 0);//总数量
            $("#subContext2020818 .aside-subContext:eq(0) .aside-txt1:eq(1) .aside-count").text(data.line.mainTotal || 0);//总数量
            $("#subContext2020818 .aside-subContext:eq(0) .aside-txt1:eq(2) .aside-count").text(data.line.branchTotal || 0);//总数量
            $("#subContext2020818 .aside-subContext:eq(0) .aside-txt1:eq(3) .aside-count").text(data.line.damagedAmount || 0);//跳闸数量
            $("#subContext2020818 .aside-subContext:eq(0) .aside-txt1:eq(4) .aside-count").text(data.line.damagedRate || 0);//跳闸数量

            _3dCharts1("_3dCharts1", 100 || 360, parseInt(data.line.damagedRate) || 0); //100/50

            $("#subContext2020818 .aside-subContext:eq(1) .aside-txt1:eq(0) .aside-count").text(data.district.total || 0);//总数量
            $("#subContext2020818 .aside-subContext:eq(1) .aside-txt1:eq(1) .aside-count").text(data.district.damagedAmount || 0);//跳闸数量
            $("#subContext2020818 .aside-subContext:eq(1) .aside-txt1:eq(2) .aside-count").text(data.district.damagedRate || 0);//跳闸数量

            _3dCharts1("_3dCharts2", 100 || 360, parseInt(data.district.damagedRate) || 0);

            $("#subContext2020818  .aside-subContext:eq(2) .aside-txt1:eq(0) .aside-count").text(data.user.total || 0);//总数量
            $("#subContext2020818  .aside-subContext:eq(2) .aside-txt1:eq(1) .aside-count").text(data.user.damagedAmount || 0);//跳闸数量
            $("#subContext2020818  .aside-subContext:eq(2) .aside-txt1:eq(2) .aside-count").text(data.user.damagedRate || 0);//跳闸数量

            _3dCharts1("_3dCharts3", 100 || 360, parseInt(data.user.damagedRate) || 0);

            $("#subContext20208181  .aside-subContext:eq(0) .aside-txt1:eq(0) .aside-count").text(data.townStreet.total || 0);//总数量
            $("#subContext20208181  .aside-subContext:eq(0) .aside-txt1:eq(1) .aside-count").text(data.townStreet.damagedAmount || 0);//跳闸数量
            $("#subContext20208181  .aside-subContext:eq(0) .aside-txt1:eq(2) .aside-count").text(data.townStreet.damagedRate || 0);//跳闸数量

            _3dCharts1("_3dCharts4", 100 || 360, parseInt(data.townStreet.damagedRate) || 0);

            $("#subContext20208181 .aside-subContext:eq(1) .aside-txt1:eq(0) .aside-count").text(data.village.total || 0);//总数量
            $("#subContext20208181 .aside-subContext:eq(1) .aside-txt1:eq(1) .aside-count").text(data.village.damagedAmount || 0);//跳闸数量
            $("#subContext20208181 .aside-subContext:eq(1) .aside-txt1:eq(2) .aside-count").text(data.village.damagedRate || 0);//跳闸数量

            _3dCharts1("_3dCharts5", 100 || 360, parseInt(data.user.damagedRate) || 0);
        },
        error: function () {
            console.log('fail');
        }
    });
}

function getAlock() {//右上角时间
    setInterval(function () {
        var date = new Date();
        var month, dates, hours, min, seconds;
        month = (date.getMonth() + 1);
        dates = date.getDate();
        hours = date.getHours();
        min = date.getMinutes();
        seconds = date.getSeconds();
        if (month < 10) {
            month = "0" + month;
        }
        if (dates < 10) {
            dates = "0" + dates;
        }
        if (hours < 10) {
            hours = "0" + hours;
        }
        if (min < 10) {
            min = "0" + min;
        }
        if (seconds < 10) {
            seconds = "0" + seconds;
        }
        var clocks = date.getFullYear() + "-" + month + "-" + dates + " " + hours + ":" + min + ":" + seconds;
        // var now=date.getFullYear()+"年"+month+"月"+(dates-1)+"日";
        $(".clock").text(clocks);
        // $("#count .main-date").text("截至" + now);
    }, 1000)
}
function getVillageDots() {
    $.ajax({
        url: basepath + "/lossPower/info",
        type: 'get',
        dataType: 'json',
        success: res => {
            if (res.code == 200) {
                res.data.forEach((item, index) => {
                    var tmpLabel = new BMap.Label(`<span class="dtdtbox" onclick="getVillage(event,${item.id})"><span class="dtdt"></span></span>`, { position: new BMap.Point(item.longitude, item.latitude), offset: new BMap.Size(-25, -25) });
                    tmpLabel.setZIndex(999);
                    tmpLabel.setStyle({
                        backgroundColor: 'rgba(255, 255, 255, 0)',
                        border: "none",
                    })
                    map.addOverlay(tmpLabel);
                    villageDots.push(tmpLabel);
                    villageDots[index].hide();
                })
            }
        }
    })

}
function getVillage(e, id) {
    $.ajax({
        url: basepath + '/lossPower/detail/' + id,
        type: 'get',
        dataType: 'json',
        success: res => {
            let div = '';
            res.data.forEach(item => {
                div = div + `<div class="center powerLossHistoryLi">${item.startTime}</div>`
            })
            $('.powerLossHistoryFor').html(div);
            $('.powerLossHistory').removeClass('hidden')
        }
    })
}
function villageDotsShowHide() {
    if (villageDotsStatus) {
        villageDotsStatus = false;
        for (let i = 0; i < villageDots.length; i++) {
            villageDots[i].hide();
        }
    } else {
        villageDotsStatus = true;
        for (let i = 0; i < villageDots.length; i++) {
            villageDots[i].show();
        }

    }

}
async function ajax(url, type, data) {
    return new Promise((resolve, reject) => {
        $.ajax({
            url: basepath + url,
            type: type ? type : 'get',
            data: data ? data : null,
            complete: res => {
                if(res.status == 200){
                    resolve(res)
                }else{
                    reject(res)
                }
            }
        })
    })
}




